namespace Ross.OA.EntityFramework.Migrations
{
    using System;
    using System.Data.Entity.Migrations;
    
    public partial class InitDB : DbMigration
    {
        public override void Up()
        {
            CreateTable(
                "dbo.Depart",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        Company = c.String(nullable: false, maxLength: 8),
                        DepartName = c.String(nullable: false, maxLength: 12),
                        DepartCode = c.String(nullable: false, maxLength: 8),
                        Powers = c.String(maxLength: 500),
                        IsActive = c.Boolean(nullable: false),
                        IsDeleted = c.Boolean(nullable: false),
                    })
                .PrimaryKey(t => t.Id);
            
            CreateTable(
                "dbo.Employee",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        Company = c.String(nullable: false, maxLength: 8),
                        UserId = c.Int(nullable: false),
                        UserName = c.String(nullable: false, maxLength: 50),
                        Password = c.String(nullable: false, maxLength: 50),
                        Powers = c.String(maxLength: 500),
                        Email = c.String(maxLength: 50),
                        Phone = c.String(maxLength: 50),
                        Address = c.String(maxLength: 100),
                        Position = c.String(maxLength: 10),
                        Sex = c.String(maxLength: 8),
                        DepartId = c.Int(nullable: false),
                        CreationTime = c.DateTime(nullable: false),
                        IsDeleted = c.Boolean(nullable: false),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.Depart", t => t.DepartId, cascadeDelete: true)
                .Index(t => t.DepartId);
            
        }
        
        public override void Down()
        {
            DropForeignKey("dbo.Employee", "DepartId", "dbo.Depart");
            DropIndex("dbo.Employee", new[] { "DepartId" });
            DropTable("dbo.Employee");
            DropTable("dbo.Depart");
        }
    }
}
